/**
 * @see https://umijs.org/docs/max/access#access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
  const { currentUser } = initialState ?? {};
  // console.log(currentUser && currentUser.access === "enterprise")
  // console.log((sessionStorage.getItem("access") === "serviceProvider"))
  // console.log(currentUser)
  // return {
  //   canAdmin: false,
  //   canEnterprise:true,
  //   canServiceProvider:true,
  //   canGovernmentAgency:true,
  //   canAccountInfo:
  //     (currentUser && currentUser.access === 'enterprise') ||
  //     sessionStorage.getItem('access') === 'enterprise' ||
  //     (currentUser && currentUser.access === 'serviceProvider') ||
  //     sessionStorage.getItem('access') === 'serviceProvider',
  // };
  return {
    canAdmin: currentUser && currentUser.access === 'admin',
    canEnterprise:
      (currentUser && currentUser.access === 'enterpise') ||
      sessionStorage.getItem('access') === 'enterpise',
    canServiceProvider:
      (currentUser && currentUser.access === 'service') ||
      sessionStorage.getItem('access') === 'service',
    canGovernmentAgency:
      (currentUser && currentUser.access === 'county') ||
      sessionStorage.getItem('access') === 'county' || (currentUser && currentUser.access === 'city') ||
      sessionStorage.getItem('access') === 'city',
    canCity: (currentUser && currentUser.access === 'city') ||
      sessionStorage.getItem('access') === 'city',
    canAccountInfo:
      (currentUser && currentUser.access === 'enterpise') ||
      sessionStorage.getItem('access') === 'enterpise' ||
      (currentUser && currentUser.access === 'service') ||
      sessionStorage.getItem('access') === 'service',
    canRate:(currentUser && currentUser.access === 'rate') ||
      sessionStorage.getItem('access') === 'rate' || (currentUser && currentUser.access === 'audit') ||
      sessionStorage.getItem('access') === 'audit' || (currentUser && currentUser.access === 'accept') ||
      sessionStorage.getItem('access') === 'accept',
    canAudit:(currentUser && currentUser.access === 'audit') ||
      sessionStorage.getItem('access') === 'audit',
    canAccept:(currentUser && currentUser.access === 'accept') ||
      sessionStorage.getItem('access') === 'accept',
  };
}
